<div id="tb<?php echo $uniqid;?>" style="padding:5px">
	<table cellspacing="0" cellpadding="0">
		<tbody>
		<tr>
			<td><input id="merchantFindmemberlistKeywords" style="width:150px" type="text" placeholder="输入会员ID或手机号"
					   class="easyui-input textbox"></td>
			<td><a href="javascript:void(0);" onclick="merchantFindmemberlistReload();" class="l-btn l-btn-small l-btn-plain"><span
					class="l-btn-left l-btn-icon-left"><i class="iconfont icon-sousuo"></i><span
					class="l-btn-text">查询</span></span></a></td>
		</tr>
		</tbody>
	</table>
</div>
<div class="con"  style="-moz-user-select:none;">
	<table id="merchantFindmemberlist"></table>
</div>
<script>
	var is_first = 1;
	var merchantFindmemberlistReload = function () {
		$("#merchantFindmemberlist").datagrid('load', {keywords: $('#merchantFindmemberlistKeywords').val(),});
	};
	var findmemberlistSearch = function () {
		$("#merchantFindmemberlist").datagrid({
			title: '',
			width: 798,
			height: 538,//高度
			singleSelect: true,//如果为true，则只允许选择一行
			striped: true,//是否显示斑马线效果。
			rownumbers: false,//如果为true，则显示一个行号列。
			pagination: true,//是否显示分页
			pageSize: 10,
			pageList: [10, 15, 20, 25],
			method: 'post',
			sortName: 'id',
			sortOrder: 'desc',
			idField: 'id',
			url: '/merchant/system/finduser',
			queryParams: {
				keywords: $('#merchantFindmemberlistKeywords').val(),
			},
			fitColumns: true,//真正的自动展开/收缩列的大小，以适应网格的宽度，防止水平滚动。
			nowrap: true,//如果为true，则在同一行中显示数据。设置为true可以提高加载性能。 是否换行
			selectOnCheck: true,
			checkOnSelect: true,
			toolbar: '#tb<?php echo $uniqid;?>',
			columns: [[
				{field: 'checkbox', title: 'checkbox', checkbox:'true', width: fixWidth(10)},
				{field: 'id', title: 'ID', width: fixWidth(10)},
				{field: 'avatar', title: '头像', width: fixWidth(10), formatter: function (value, rowData, rowIndex) {
					return value ? "<img height='30px' src='" + value + "'>" : '';
				}},
				{field: 'nickname', title: '用户昵称', width: fixWidth(25)},
				{field: 'phone', title: '手机号', width: fixWidth(25)},
				{field: 'level_info', title: '身份', width: fixWidth(20), formatter(value, rowData) {
					return value.length ? value.name : '普通会员';
				}},
			]],
			onBeforeLoad:function () {
				if(is_first){
					return false;
				}
				if($('#merchantFindmemberlistKeywords').val() === ''){
					$.messager.alert('提示','请输入查询信息','warning');
					return false;
				}
				if(!/[0-9]+/.test($('#merchantFindmemberlistKeywords').val())){
					$.messager.alert('提示','查询信息不正确','warning');
					return false;
				}
			}
		});
		is_first = 0;
	};
	findmemberlistSearch();
	$('#merchantFindmembersubmit').click(function (data) {
		var rows = $('#merchantFindmemberlist').datagrid('getChecked');
		if (rows.length) {
			merchantUserAddVm.member_name = `${rows[0].nickname}(${rows[0].phone})`;
			merchantUserAddVm.params.member_id = rows[0].id;
		}
		$("#merchantUserAdddlg").dialog('close');
	});
</script>
